package com.hxd.otc.module.my.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.my.bean.ExchangeRecordBean;
import com.hxd.otc.module.my.contract.ExchangeDetailContract;
import com.hxd.otc.module.my.model.ExchangeModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

/**
 * Created by lzy on 2019/1/4 0004.
 * description ${兑换详情Presenter}
 */
public class ExchangeDetailPresenter extends BasePresenter<ExchangeDetailContract.IView> implements ExchangeDetailContract.IPresenter {

    private final ExchangeModel mExchangeModel;

    public ExchangeDetailPresenter(ExchangeDetailContract.IView iView) {
        super(iView);
        mExchangeModel = ExchangeModel.getInstance();
    }

    @Override
    public void queryOrderDetail(String orderId) {
        mExchangeModel.queryOrderDetail(orderId, new BaseObserver<ExchangeRecordBean>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull ExchangeRecordBean exchangeRecordBean) {
                mView.queryOrderDetailSuccess(exchangeRecordBean);
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.showToast(errMessage);
            }
        }, mView.<BaseBean<ExchangeRecordBean>>bindAutoDispose());
    }
}
